package org.sbbs.base.entity;

import java.util.UUID;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;

@MappedSuperclass
public abstract class UUIDBaseEntity extends BaseEntity {

    protected String id;

    @Id
    @NotNull
    @Basic
    @Column(name = "ID", length = 32, nullable = false)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public UUIDBaseEntity() {
        this.id = UUID.randomUUID().toString().replaceAll("-", "");
    }
}
